<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link th:href="@{/webjars/bootstrap/3.4.1/css/bootstrap.css}" rel="stylesheet">
</head>
<body>
<div class="container" style="margin-left: 550px;margin-top: 200px;">
    <form class="form-horizontal" role="form" action="/Page" method="post">
        <div class="form-group">
            <label for="email" class="col-auto">邮箱:</label>
            <label class="col-auto">
                <input type="text" name="email" class="form-control" id="email" placeholder="请输入邮箱" style="width:200px">
            </label>
        </div>
        <div class="form-group">
            <label for="password" class="col-auto">密码:</label>
            <label class="col-auto">
                <input type="password" name="password" class="form-control" id="password" placeholder="请输入密码" style="width:200px">
            </label>
        </div>
        <div class="form-group">
            <label class="col-auto">
                <input type="radio" name="option" id="studentOption" value="学生" checked>
                学生</label>
            <label class="col-auto">
                <input type="radio" name="option" id="teacherOption" value="教师">
                教师</label>
        </div>
        <div class="align-bottom col-auto" style="margin-left: 80px">
            <button type="submit" value="登录" class="btn btn-primary btn-sm" id="login">登录</button>
        </div>
        <div class="form-group">
            <p class="message">还没有账户? <a href="/studentReg"><span class="glyphicon glyphicon-user"></span>学生注册</a> <a
                    href="/teacherReg"><span class="glyphicon glyphicon-user"></span>教师注册</a></p>
        </div>
        <div class="form-group">
            <a href="/adminLogin"><span class="glyphicon glyphicon-user"></span>管理员登录</a></a>
        </div>
    </form>
</div>
<script th:src="@{/webjars/jquery/3.4.1/jquery.js}"></script>
<script>
    //用ajax传递的邮箱和密码，也可以用，但是有点麻烦就直接用submit提交了
    // $("#login").click(function () {
    //     var email = $("#email").val();
    //     var password = $("#password").val();
    //     // var userData = {};
    //     // userData['email'] = email;
    //     // userData['password'] = password;
    //     $.ajax({
    //         type: "POST",
    //         url: "/getEmailPassword",
    //         data: {
    //             "email": email,
    //             "password": password
    //         },
    //         dataType: "json",
    //         success: function (result) {
    //             if (result.success == true) {
    //                 // window.open("http://localhost:8081/studentReg");
    //                 window.location.href = "http://localhost:8081/studentPage";
    //             }else
    //                 alert("用户不存在或者密码错误")
    //         },
    //         error: function () {
    //             alert("失败");
    //         }
    //     });
    // });

    // if (email == "<!--数据库中已有用户邮箱-->" && password == "<!--数据库中已有邮箱对应密码-->")<!--与数据库中登录表已有的用户邮箱和密码匹配，判断是否正确-->
    // {
    //     alert("登录成功！");
    //     $("#user_name").val("");
    //     $("#password").val("");
    //
    // } else {
    //     alert("用户邮箱或密码不正确！");
    // }


</script>
</body>
</html>